<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const fn = function (a, b, c, d, e) {
        //arguments动态参数能接受所有传入的实参

        console.log(a, b, c, d, e)
        console.log(arguments)

        //准备一个求和的变量
        let sum = 0

        for (let i = 0; i < arguments.length; i++) {
          sum += arguments[i]
        }
        // Array.prototype.forEach.call(arguments, function (item) {
        //   sum += item
        // })

        return sum
      }

      const sum = fn(1, 2, 3, 4)

      console.log(sum)
    </script>
  </body>
</html>
